Skip to content

Conversation

@pranaygp
Copy link
Collaborator

Improves type safety by creating discriminated union types for builder-specific
configurations, making it clear which configuration options are required for
each builder type.

Changes:

  • Created BaseWorkflowConfig interface with common options
  • Created StandaloneConfig, VercelBuildOutputConfig, and NextConfig types
  • Made WorkflowConfig a discriminated union based on buildTarget
  • Added documentation for each configuration type
  • Exported new types from @workflow/builders

This enables better IntelliSense and type checking when constructing builder
configurations, preventing invalid configuration combinations at compile time.

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2025

🦋 Changeset detected

Latest commit: 9c754af

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/sveltekit Patch
workflow Patch
@workflow/world-testing Patch
@workflow/ai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Oct 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Comment Nov 4, 2025 7:16am
example-nextjs-workflow-webpack Ready Ready Preview Comment Nov 4, 2025 7:16am
example-workflow Ready Ready Preview Comment Nov 4, 2025 7:16am
workbench-nitro-workflow Ready Ready Preview Comment Nov 4, 2025 7:16am
workbench-nuxt-workflow Ready Ready Preview Comment Nov 4, 2025 7:16am
workbench-sveltekit-workflow Ready Ready Preview Comment Nov 4, 2025 7:16am
workbench-vite-workflow Ready Ready Preview Comment Nov 4, 2025 7:16am
workflow-docs Ready Ready Preview Comment Nov 4, 2025 7:16am

@TooTallNate
Copy link
Member

@copilot Can you try to fix the build error?

@workflow/sveltekit:build: src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

Copilot AI commented Nov 4, 2025

@TooTallNate I've opened a new pull request, #200, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig type is missing the SvelteKitConfig interface, causing TypeScript to reject buildTarget: 'sveltekit' in the SvelteKit builder. While 'sveltekit' is included in the validBuildTargets array, there's no corresponding interface in the discriminated union.

View Details
📝 Patch Details
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined

Analysis

Missing SvelteKit configuration interface causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts:25:7 due to missing SvelteKitConfig interface in the WorkflowConfig union type

How to reproduce:

cd packages/sveltekit && pnpm run build

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig discriminated union type is missing SvelteKitConfig, causing TypeScript to reject buildTarget: 'sveltekit' assignments. The validBuildTargets array includes 'sveltekit' but the corresponding interface and union type member were not defined.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
   StandaloneConfig,
   VercelBuildOutputConfig,
   NextConfig,
+  SvelteKitConfig,
 } from './types.js';
 export { validBuildTargets, isValidBuildTarget } from './types.js';
 export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined

Analysis

Missing SvelteKitConfig type causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts:25:7 due to missing SvelteKitConfig interface in the WorkflowConfig discriminated union

How to reproduce:

cd packages/sveltekit && pnpm run build

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig union type was missing a SvelteKitConfig interface, causing TypeScript to reject the buildTarget: 'sveltekit' assignment in the SvelteKit builder constructor.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
   StandaloneConfig,
   VercelBuildOutputConfig,
   NextConfig,
+  SvelteKitConfig,
 } from './types.js';
 export { validBuildTargets, isValidBuildTarget } from './types.js';
 export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined
diff --git a/packages/sveltekit/src/builder.ts b/packages/sveltekit/src/builder.ts
index 90409d3..3427c4e 100644
--- a/packages/sveltekit/src/builder.ts
+++ b/packages/sveltekit/src/builder.ts
@@ -1,7 +1,7 @@
 import { constants } from 'node:fs';
 import { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
 import { join, resolve } from 'node:path';
-import { BaseBuilder, type WorkflowConfig } from '@workflow/builders';
+import { BaseBuilder, type SvelteKitConfig } from '@workflow/builders';
 
 // Helper function code for converting SvelteKit requests to standard Request objects
 const SVELTEKIT_REQUEST_CONVERTER = `
@@ -18,15 +18,15 @@ async function convertSvelteKitRequest(request) {
 `;
 
 export class SvelteKitBuilder extends BaseBuilder {
-  constructor(config?: Partial<WorkflowConfig>) {
+  constructor(config?: Partial<SvelteKitConfig>) {
     super({
-      ...config,
       dirs: ['workflows'],
       buildTarget: 'sveltekit' as const,
       stepsBundlePath: '', // unused in base
       workflowsBundlePath: '', // unused in base
       webhookBundlePath: '', // unused in base
-      workingDir: config?.workingDir || process.cwd(),
+      workingDir: process.cwd(),
+      ...config,
     });
   }
 

Analysis

Missing SvelteKitConfig in TypeScript union type causes compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in WorkflowConfig union type

How to reproduce:

cd packages/sveltekit && pnpm build

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig discriminated union was missing a SvelteKitConfig interface, causing TypeScript to reject the 'sveltekit' build target as an invalid type.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
   StandaloneConfig,
   VercelBuildOutputConfig,
   NextConfig,
+  SvelteKitConfig,
 } from './types.js';
 export { validBuildTargets, isValidBuildTarget } from './types.js';
 export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined

Analysis

Missing SvelteKitConfig type causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts due to missing SvelteKitConfig interface in the WorkflowConfig discriminated union

How to reproduce:

pnpm turbo build --filter='@workflow/sveltekit'

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig union type was missing the SvelteKitConfig interface, even though 'sveltekit' was included in the validBuildTargets array, causing a TypeScript error when trying to use buildTarget: 'sveltekit' in the SvelteKit builder.

View Details
📝 Patch Details
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined

Analysis

Missing SvelteKitConfig interface causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in the WorkflowConfig union type

How to reproduce:

cd packages/sveltekit && pnpm run build

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig type union is missing the SvelteKitConfig interface, even though 'sveltekit' was added as a valid build target. This causes TypeScript to reject buildTarget: 'sveltekit' in the SvelteKit builder.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
   StandaloneConfig,
   VercelBuildOutputConfig,
   NextConfig,
+  SvelteKitConfig,
 } from './types.js';
 export { validBuildTargets, isValidBuildTarget } from './types.js';
 export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined

Analysis

Missing SvelteKitConfig type causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in the WorkflowConfig union type

How to reproduce:

cd packages/sveltekit && pnpm run build

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The validBuildTargets array includes 'sveltekit' but the WorkflowConfig type union was missing the corresponding SvelteKitConfig interface, causing TypeScript to reject 'sveltekit' as a valid buildTarget value.

View Details
📝 Patch Details
diff --git a/packages/builders/src/index.ts b/packages/builders/src/index.ts
index 5d9997b..344f785 100644
--- a/packages/builders/src/index.ts
+++ b/packages/builders/src/index.ts
@@ -7,6 +7,7 @@ export type {
   StandaloneConfig,
   VercelBuildOutputConfig,
   NextConfig,
+  SvelteKitConfig,
 } from './types.js';
 export { validBuildTargets, isValidBuildTarget } from './types.js';
 export type { WorkflowManifest } from './apply-swc-transform.js';
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined
diff --git a/packages/sveltekit/src/builder.ts b/packages/sveltekit/src/builder.ts
index 90409d3..c49fa67 100644
--- a/packages/sveltekit/src/builder.ts
+++ b/packages/sveltekit/src/builder.ts
@@ -1,7 +1,7 @@
 import { constants } from 'node:fs';
 import { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
 import { join, resolve } from 'node:path';
-import { BaseBuilder, type WorkflowConfig } from '@workflow/builders';
+import { BaseBuilder, type SvelteKitConfig } from '@workflow/builders';
 
 // Helper function code for converting SvelteKit requests to standard Request objects
 const SVELTEKIT_REQUEST_CONVERTER = `
@@ -18,7 +18,7 @@ async function convertSvelteKitRequest(request) {
 `;
 
 export class SvelteKitBuilder extends BaseBuilder {
-  constructor(config?: Partial<WorkflowConfig>) {
+  constructor(config?: Partial<SvelteKitConfig>) {
     super({
       ...config,
       dirs: ['workflows'],

Analysis

Missing SvelteKitConfig interface causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts line 25 due to missing SvelteKitConfig interface in the builders package type system

How to reproduce:

cd packages/sveltekit && npx tsc --noEmit --skipLibCheck src/builder.ts

Result:

src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Build Fix:

The WorkflowConfig union type is missing the SvelteKitConfig interface, causing TypeScript to reject buildTarget: 'sveltekit' assignments even though 'sveltekit' is a valid build target.

View Details
📝 Patch Details
diff --git a/packages/builders/src/types.ts b/packages/builders/src/types.ts
index b79a233..5c51414 100644
--- a/packages/builders/src/types.ts
+++ b/packages/builders/src/types.ts
@@ -55,13 +55,25 @@ export interface NextConfig extends BaseWorkflowConfig {
   webhookBundlePath: string;
 }
 
+/**
+ * Configuration for SvelteKit builds.
+ */
+export interface SvelteKitConfig extends BaseWorkflowConfig {
+  buildTarget: 'sveltekit';
+  // SvelteKit builder computes paths dynamically, so these are not used
+  stepsBundlePath: string;
+  workflowsBundlePath: string;
+  webhookBundlePath: string;
+}
+
 /**
  * Discriminated union of all builder configuration types.
  */
 export type WorkflowConfig =
   | StandaloneConfig
   | VercelBuildOutputConfig
-  | NextConfig;
+  | NextConfig
+  | SvelteKitConfig;
 
 export function isValidBuildTarget(
   target: string | undefined

Analysis

Missing SvelteKitConfig interface causes TypeScript compilation failure

What fails: TypeScript compiler fails on packages/sveltekit/src/builder.ts:25 due to missing SvelteKitConfig interface in the WorkflowConfig union type

How to reproduce:

pnpm turbo build --filter=@workflow/sveltekit

Result:

[ERROR] @workflow/sveltekit:build: src/builder.ts(25,7): error TS2322: Type '"sveltekit"' is not assignable to type '"standalone" | "vercel-build-output-api" | "next"'.
[ERROR] @workflow/sveltekit:build:  ELIFECYCLE  Command failed with exit code 2.

.
Signed-off-by: Nathan Rajlich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants